const express = require('express')
const app = express()


app.use(function(req,res,next){
    
    //把中间件转交给下一个next函数
    const time=Date.now()
    req.startTime=time
    next()
})

app.get('/', (req, res) => {
    console.log("调用了home"+req.startTime)
    res.send('home')
})
app.get('/user', (req, res) => {
    console.log("调用了user"+req.startTime)
    res.send('userpage')
})

app.listen(8080, () => {
    console.log('express,at http://127.0.0.1:8080')
})